<?php

namespace App\Remote\Guanyuan;

use GuzzleHttp\Exception\GuzzleException;
use Symfony\Component\HttpFoundation\Request as RequestAlias;

class GuanyuanRemote extends Remote
{

    /**
     * @param string $source
     * @param string $token
     * @param array $filters
     * @param int $cacheTime
     * @return array|mixed
     * @throws GuzzleException
     */
    public static function sourceData(string $source, string $token, array $filters = [], int $cacheTime = 700)
    {
        try {
            return self::customRequestV2(
                "public-api/data-source/{$source}/token/{$token}",
                RequestAlias::METHOD_POST,
                ['filters' => $filters],
                null,
                null,
                $cacheTime
            );
        } catch (\Exception $exception) {
            logException("观远请求错误", $exception, null, true, true);
            return [];
        }
    }
}
